class Scdoc < Formula
  desc "Small man page generator"
  homepage "https://git.sr.ht/~sircmpwn/scdoc/"
  url "https://git.sr.ht/~sircmpwn/scdoc/archive/1.10.1.tar.gz"
  sha256 "80e021c732cca2cd6659dccf3306d46f59eecbf8fbaa4dabdb502f537278a78f"

  bottle do
    cellar :any_skip_relocation
    sha256 "d4a577f0a76e9c1d731163daec2596a6fbee94fddbfc94e2a6b07c7be9ae09b6" => :catalina
    sha256 "752b2cab0f59547dd2abae83399f5e23fa9bae18e27a087e89dc5c0dd80966ea" => :mojave
    sha256 "dcee18bf4f3d6ffa25fed921cbd71de0d31a097e9ec9d3cd707e1ccd02663e70" => :high_sierra
  end

  def install
    # scdoc sets by default LDFLAGS=-static which doesn't work on macos(x)
    system "make", "LDFLAGS=", "PREFIX=#{prefix}"
    system "make", "install", "PREFIX=#{prefix}"
  end

  test do
    preamble = <<~EOF
      .\\" Generated by scdoc #{version}
      .\\" Complete documentation for this program is not available as a GNU info page
      .ie \\n(.g .ds Aq \\(aq
      .el       .ds Aq '
      .nh
      .ad l
      .\\" Begin generated content:
    EOF
    assert_equal preamble, shell_output("#{bin}/scdoc </dev/null")
  end
end
